home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / msdos / css / source / dataset.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-19  |  26.7 KB  |  849 lines

  1.  
  2. #include <process.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <glib.h>
  7. #include <strlib.h>
  8. #include "land.h"
  9.  
  10.  /* #include "..\lib.h" */
  11.  
  12. void dsetmsg(int com, int sw)
  13. {
  14.    char hmsg1[80], hmsg2[80];
  15.    int col;
  16.  
  17.    hmsg1[0] = '\0'; hmsg2[0] = '\0';
  18.  
  19.    if (com == 1) {
  20.       strcpy(hmsg1, "ドライブ0から作業領域へデータを読み込みます。");
  21.       strcpy(hmsg2, "作業領域を選択してください。");
  22.    }
  23.  
  24.    if (com == 2) {
  25.       strcpy(hmsg1, "ドライブ1から作業領域へデータを読み込みます。");
  26.       strcpy(hmsg2, "作業領域を選択してください。");
  27.    }
  28.  
  29.    if (com == 3) {
  30.       strcpy(hmsg1, "ドライブ2から作業領域へデータを読み込みます。");
  31.       strcpy(hmsg2, "作業領域を選択してください。");
  32.    }
  33.  
  34.    if (com == 4) {
  35.       strcpy(hmsg1, "ドライブ3から作業領域へデータを読み込みます。");
  36.       strcpy(hmsg2, "作業領域を選択してください。");
  37.    }
  38.  
  39.    if (com == 6) {
  40.       strcpy(hmsg1, "メイン・メニューにもどります。");
  41.    }
  42.  
  43.    if (sw == 0) col = col7;
  44.    else         col = col0;
  45.  
  46.    msgset(96, 255, hmsg1, col);
  47.    msgset(96, 275, hmsg2, col);
  48. }
  49.  
  50.  
  51. void migiya(int x, int y, int col)
  52. {
  53. int bcl[16];
  54.  
  55.    bcl[0] = col;
  56.    line(x,   y+4, x+29, y+19,  PSET, col, 2, 0xffff);
  57.    line(x+29,y,   x+29, y+23,  PSET, col, 0, 0xffff);
  58.    line(x+29,y,   x+39, y+12,  PSET, col, 0, 0xffff);
  59.    line(x+29,y+23,x+39, y+12,  PSET, col, 0, 0xffff);
  60.    paint(x+30,y+12, 1, col,  1, bcl);
  61. }
  62.  
  63. void recogmsg(int x, int y, int col)
  64. {
  65.    if (col < 0) {
  66.       line(x-2, y-2, x+33, y+18, PSET, col15, 1, 0xffff);
  67.       line(x-1, y-1, x+32, y+17, PSET, col0,  2, 0xffff);
  68.       msgset(x, y, "確認", col15);
  69.    } else {
  70.       line(x-2, y-2, x+33, y+18, PSET, col,  1, 0xffff);
  71.       line(x-1, y-1, x+32, y+17, PSET, col7, 2, 0xffff);
  72.       msgset( x, y, "確認", col);
  73.    }
  74. }
  75.  
  76. void escmsg(int x, int y, int col)
  77. {
  78.    if (col < 0) {
  79.       line(x-2, y-2, x+33, y+18, PSET, col15, 1, 0xffff);
  80.       line(x-1, y-1, x+32, y+17, PSET, col0,  2, 0xffff);
  81.       msgset(x, y, "中止", col15);
  82.    } else {
  83.       line(x-2, y-2, x+33, y+18, PSET, col,  1, 0xffff);
  84.       line(x-1, y-1, x+32, y+17, PSET, col7, 2, 0xffff);
  85.       msgset( x, y, "中止", col);
  86.    }
  87. }
  88.  
  89. /* return( ok = 0,  no = -1) , if (sw == 0) recog only */
  90. int recogin(int x, int y, int sw)
  91. {
  92. int mx, my;
  93.  
  94.    recogmsg(x, y, col0);
  95.    if (sw != 0) escmsg(x+40, y, col0);
  96.    while (1) {
  97.       while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
  98.       if (xychk(mx, my,x,y, x+33, y+18) == 1) {
  99.          recogmsg(x, y, -1);
  100.          while((MOS_rdpos(&mx, &my) & 0x01) == 1);
  101.          if (xychk(mx, my, x, y, x+33, y+18) == 0) {
  102.             recogmsg(x, y, col0);
  103.             continue;
  104.          } else {
  105.             return(0);
  106.          }
  107.       }
  108.       if ((sw != 0) && (xychk(mx, my,x+40, y, x+73, y+18) == 1)) {
  109.          escmsg(x+40, y, -1);
  110.          while((MOS_rdpos(&mx, &my) & 0x01) == 1);
  111.          if (xychk(mx, my, x+40, y, x+73, y+18) == 0) {
  112.             escmsg(x+40, y, col0);
  113.             continue;
  114.          } else {
  115.             return(-1);
  116.          }
  117.       }
  118.    }
  119. }
  120.  
  121. /* return( non = 0,  rec = 1, esc = -1;) , if (sw == 0) recog only */
  122. int recogin2(int mx, int my, int x, int y, int sw)
  123. {
  124.       if (xychk(mx, my,x,y, x+33, y+18) == 1) {
  125.          recogmsg(x, y, -1);
  126.          while((MOS_rdpos(&mx, &my) & 0x01) == 1);
  127.          if (xychk(mx, my, x, y, x+33, y+18) == 0) {
  128.             recogmsg(x, y, col0);
  129.             return(0); /* continue; */
  130.          } else {
  131.             return(1); /* rec */
  132.          }
  133.       }
  134.       if ((sw != 0) && (xychk(mx, my,x+40, y, x+73, y+18) == 1)) {
  135.          escmsg(x+40, y, -1);
  136.          while((MOS_rdpos(&mx, &my) & 0x01) == 1);
  137.          if (xychk(mx, my, x+40, y, x+73, y+18) == 0) {
  138.             escmsg(x+40, y, col0);
  139.             return(0); /* continue; */
  140.          } else {
  141.             return(-1); /*esc */
  142.          }
  143.       }
  144.       return(0);
  145. }
  146.  
  147.  
  148. void wareaerr(int warea)
  149. {
  150. char  msg[80];
  151.  
  152.    helpcls( 80, 230, 560, 300);
  153.    sprintf( msg, "作業領域 %d にエラーが発生しました。", warea);
  154.    msgset(96, 255, msg, col10);
  155.    msgset(96, 275, "確認ボタンを押してください。", col10);
  156.    recogin( 435, 275, 0);
  157.    return;
  158. }
  159.  
  160. void drverr(int drv)
  161. {
  162. char msg[80];
  163.  
  164.    helpcls( 80, 230, 560, 300);
  165.    sprintf( msg, "ドライブ%2d にエラーが発生しました。", drv);
  166.    msgset(96, 255, msg, col10);
  167.    msgset(96, 275, "確認ボタンを押してください。", col10);
  168.    recogin( 435, 275, 0);
  169.    return;
  170. }
  171.  
  172.  
  173. /* return:  normal = 0; error = -1; */
  174. int headblkpri(unsigned char headblk[], int drv)
  175. {
  176. char msg1[80];
  177. char msg2[80];
  178. int  secnum;
  179. char wwS[80], wS[80], wS2[80], satS[10], sensorS[10];
  180. int  x,y, vol, nvol;
  181.  
  182.    x = 60; y = 65;
  183.  
  184.    helpcls( x, y, x+390, y+120); /* clear head print area */
  185.    
  186.    strmid(wS, headblk, 69, 6);
  187.    if (strcmp(wS, "RESTEC") != 0) {
  188.       helpcls( 80, 230, 560, 300);
  189.       sprintf( msg1, "ドライブ%2d は LANDSAT/MOS ディスクではありません。", drv);
  190.       msgset(96, 255, msg1, col10);
  191.       msgset(96, 275, "確認ボタンを押してください。", col10);
  192.       recogin( 435, 275, 0);
  193.       return(-1);
  194.    }
  195.    strmid(wwS, headblk,  9, 4);
  196.    strmid(wS,  headblk, 25, 4);
  197.    if ((atoi(wwS) != 1) || (atoi(wS) != 1)) {
  198.       helpcls( 80, 230, 560, 300);
  199.       sprintf( msg1, "この LANDSAT/MOS ディスクは間引き率が1ではありません。", drv);
  200.       msgset(96, 255, msg1, col10);
  201.       msgset(96, 275, "確認ボタンを押してください。", col10);
  202.       recogin( 435, 275, 0);
  203.       return(-1);
  204.    }
  205.  
  206.    strmid(wS, headblk, 140, 1);
  207.    if (strcmp(wS, "M") == 0) { strcpy(satS, "LANDSAT"); strcpy(sensorS, "MSS"); }
  208.    if (strcmp(wS, "T") == 0) { strcpy(satS, "LANDSAT"); strcpy(sensorS, "TM"); }
  209.    if (strcmp(wS, "E") == 0) { strcpy(satS, "MOS"); strcpy(sensorS, "MESSR"); }
  210.    if (strcmp(wS, "V") == 0) { strcpy(satS, "MOS"); strcpy(sensorS, "VTIR"); }
  211.  
  212.    nvol = atoi(strmid(wS, headblk, 217, 4)); if (nvol == 0) nvol = 1;
  213.    vol  = atoi(strmid(wS, headblk, 221, 4)); if (vol  == 0) vol  = 1;
  214.  
  215.    sprintf(wwS, "%s-%s %s   VOL%d/%d", satS, strmid(wS, headblk, 191, 1), sensorS, vol, nvol);
  216.    msgset2(x+8, y+25, wwS, col0);
  217.    sprintf(wwS, "LINE   (START,END,INT) ... %s  %s", strmid(wS, headblk,  1, 4), strmid(wS2, headblk,  5, 8));
  218.    msgset2(x+8, y+35, wwS, col0);
  219.    sprintf(wwS, "LINES  ................... %s",     strmid(wS, headblk, 13, 4));
  220.    msgset2(x+8, y+45, wwS, col0);
  221.    sprintf(wwS, "PIXEL  (START,END,INT) ... %s  %s", strmid(wS, headblk, 17, 4), strmid(wS2, headblk, 21, 8));
  222.    msgset2(x+8, y+55, wwS, col0);
  223.    sprintf(wwS, "PIXELS ................... %s",     strmid(wS, headblk, 29, 4));
  224.    msgset2(x+8, y+65, wwS, col0);
  225.    sprintf(wwS, "%s", strmid(wS, headblk,  89, 8));
  226.    msgset2(x+8, y+75, wwS, col0);
  227.    sprintf(wwS, "%s", strmid(wS, headblk,  97, 43));
  228.    msgset2(x+8, y+85, wwS, col0);
  229.    sprintf(wwS, "%s", strmid(wS, headblk, 140, 36));
  230.    msgset2(x+8, y+95, wwS, col0);
  231.    sprintf(wwS, "%s", strmid(wS, headblk, 176, 29));
  232.    msgset2(x+8,y+105, wwS, col0);
  233.    return(0);
  234. }
  235. /* input vol = 0:non select, > 0:select; return 0 == no error, -10 == error */
  236. int volchg(int vol, int drv, unsigned char headblk[])
  237. {
  238. char msg[80];
  239. int  devno, ret, ercnt;
  240. unsigned  mode1, mode2;
  241. int  cylno, hedno, secno, seccnt, secnum;
  242.  
  243.    do { 
  244.       helpcls( 80, 230, 560, 300);
  245.       if (vol == 0) sprintf( msg, "ドライブ %d にデータ・ディスクをセットしてから", drv);
  246.       else sprintf( msg, "ドライブ %d にデータ・ディスク Volume %d をセットしてから", drv, vol);
  247.       msgset(96, 255, msg, col0);
  248.       msgset(96, 275, "確認ボタンを押してください。", col0);
  249.       if (recogin( 435, 275, 1) != 0) return(-1);
  250.       
  251.       devno = 0x0020 | drv; /* 1MB floppy */
  252.       mode1 = 0x0001;       /* MFM, 2HD, 256 */
  253.       mode2 = 0x021a;       /* 2Head, 26sector */
  254.       ret = DKB_setmode(devno, mode1, mode2);
  255.  
  256.       cylno = 1; hedno = 0; secno = 1; seccnt = 2;
  257.       ercnt = 0;
  258.       while(1) {
  259.          ret = DKB_restore(devno);
  260.          if (DKB_read( devno, cylno, hedno, secno, seccnt, headblk, &secnum) == 0) break;
  261.          { int i; for (i = 0; i < 30000; i++); }
  262.          if (++ercnt > 9) { drverr(drv); return(-1); }
  263.       }
  264.       if (headblkpri(headblk, drv) == -1) { return(-1); }
  265.       if (vol == 0) return(0);
  266.    } while (atoi(strmid(msg, headblk, 221, 4)) != vol);
  267.    return(0);
  268. }
  269.  
  270.  
  271. int dataset3(int drv, int warea)
  272. {
  273. int  mx, my, wx, wy, wi;
  274. int  cx = 400, cy = 200;
  275. char msg1[80];
  276. char msg2[80];
  277. int  x, y, devno, ret;
  278. unsigned  mode1, mode2;
  279. int  cylno, hedno, secno, seccnt;
  280. unsigned char headblk[2][512], wblk[512];
  281. int  secnum;
  282. char wname[64];
  283. FILE *fp;
  284. char wwS[80], wS[80], wS2[80], satS[10], sensorS[10];
  285. char fmatS[5], bndtblS[10];
  286. int  nch, nvol, vol;
  287. int  i, j, ercnt;
  288. double wdf;
  289. size_t bsize, bn;
  290. int  ys, ye, v, linst,linest, s;
  291. int  trk, sid, sct, ch;
  292.  
  293.    sprintf(wname, "%s\\warea%1d.lnd", workdir, warea);
  294.    linest = 1;
  295.    x = 60; y = 65;
  296.  
  297.    if (volchg( 0, drv, headblk[1]) == -1) return(-1); /* no select volume */
  298.    
  299.    strmid(wS, headblk[1], 140, 1);
  300.    if (strcmp(wS, "M") == 0) { strcpy(satS, "LANDSAT"); strcpy(sensorS, "MSS"); }
  301.    if (strcmp(wS, "T") == 0) { strcpy(satS, "LANDSAT"); strcpy(sensorS, "TM"); }
  302.    if (strcmp(wS, "E") == 0) { strcpy(satS, "MOS"); strcpy(sensorS, "MESSR"); }
  303.    if (strcmp(wS, "V") == 0) { strcpy(satS, "MOS"); strcpy(sensorS, "VTIR"); }
  304.    
  305.    strmid( fmatS, headblk[1], 34, 3);
  306.    nch = atoi(strmid( wS, headblk[1], 37, 4));
  307.    strmid( bndtblS, headblk[1], 142, 7);
  308.    nvol = atoi(strmid(wS, headblk[1], 217, 4)); if (nvol == 0) nvol = 1;
  309.    vol  = atoi(strmid(wS, headblk[1], 221, 4)); if (vol  == 0) vol  = 1;
  310.  
  311.    helpcls( 80, 230, 560, 300);
  312.    sprintf( msg1, "バンド番号を下から選択して下さい。");
  313.    msgset(96, 255, msg1, col0);
  314.    
  315.    sprintf(msg2, "%c %c %c %c %c %c %c", bndtblS[0], bndtblS[1], bndtblS[2], bndtblS[3], bndtblS[4], bndtblS[5], bndtblS[6]);
  316.    msgset(96, 275, msg2, col12);
  317.    wx = 435, wy = 275;
  318.    recogmsg(wx, wy, col0); escmsg(wx+40, wy, col0);
  319.    ch = 0; j = 0;
  320.    while(1) {
  321.       while((MOS_rdpos(&mx, &my) & 0x01) == 0);
  322.       wy = 275;
  323.       for (i = 0; i < 7; i++) {
  324.          wx = 96+16*i;
  325.          if ((xychk(mx, my, wx, wy, wx+8, wy+16) == 1) && (bndtblS[i] != ' ')) {
  326.             line(96+16*j-1, wy-1, 96+16*j+9, wy+17, PSET, col7, 1, 0xffff);
  327.             line(wx-1, wy-1, wx+9, wy+17, PSET, col14, 1, 0xffff);
  328.             ch = bndtblS[i] - '0'; j = i;
  329.          }
  330.       }
  331.       wx = 435, wy = 275;
  332.       wi = recogin2( mx, my, wx, wy, 1);
  333.       if (wi == -1) return(-1);
  334.       if (wi == 1) {
  335.         if (ch != 0) break;
  336.         recogmsg(wx, wy, col0);
  337.       }
  338.       while((MOS_rdpos(&mx, &my) & 0x01) == 1);
  339.    }
  340.    
  341.   /* start */
  342.    ys = 0; ye = 399;
  343.    v = vol;
  344.    
  345.    if (strcmp(sensorS, "VTIR") == 0) {
  346.       helpcls( 80, 230, 560, 300);
  347.       msgset(96, 255, "LANDSAT/MOS データの読み取り開始ラインを入力して下さい。", col0);
  348.       msgset(96, 275, "[ 1 ~ 801 ]", col0);
  349.       msgset(112, 275, "1", col13);
  350.       if (recogin( 435, 275, 1) != 0) return(-1);
  351.       wx = 435, wy = 275;
  352.       recogmsg(wx, wy, col0); escmsg(wx+40, wy, col0);
  353.       linst = 1; j = 0;
  354.       while(1) {
  355.          while((MOS_rdpos(&mx, &my) & 0x01) == 0);
  356.          wx = 112;
  357.          if (xychk(mx, my, wx, wy, wx+32, wy+16) == 1) {
  358.             line(wx-1, wy-1, wy+9, wy+17, PSET, col14, 1, 0xffff);
  359.             wdf = linst;
  360.             if (calc( &cx, &cy, &wdf) != 0) {
  361.                if (wdf < 1)        linst = 1;
  362.                else if (wdf > 801) linst = 801;
  363.                else linst = wdf;
  364.                linest = linst;
  365.             }
  366.             line(wx-1, wy-1, wx+9, wy+17, PSET, col7, 2, 0xffff);
  367.             sprintf(msg2, "%d", linst);
  368.             msgset(112, 275, msg2, col13);
  369.          }
  370.          wx = 435, wy = 275;
  371.          wy = recogin2( mx, my, wx, wy, 1);
  372.          if (wy == -1) return(-1);
  373.          if (wy ==  1) break;
  374.          while((MOS_rdpos(&mx, &my) & 0x01) == 1);
  375.       }
  376.       
  377.       if (strcmp(fmatS, "BSQ") == 0) {
  378.          vol = ch; j = linst*2+1;
  379.       } else {
  380.          vol = (linst-1)/400+1;
  381.          linst = linst - (vol-1)*400;
  382.          ye = 400-linst;
  383.          j = (linst-1)*nch*2 + ch*2 + 1;
  384.       }
  385.       trk = (j-1) / 52 + 1;
  386.       j = j - (j / 52) * 52;
  387.       if (j > 26) {
  388.          sid = 1; sct = j - 26;
  389.       } else {
  390.          sid = 0; sct = j;
  391.       }
  392.       if (vol != v) {
  393.          if (volchg(vol, drv, headblk[1]) == -1) return(-1);
  394.       }
  395.    }
  396.       
  397.    if (strcmp(fmatS, "BSQ") == 0) {
  398.       sct = 3;
  399.       switch (ch) {
  400.          case 1:  trk =  1; sid = 0; vol = 1; break;
  401.          case 2:  trk = 16; sid = 1; vol = 1; break;
  402.          case 3:  trk = 32; sid = 0; vol = 1; break;
  403.          case 4:  trk = 47; sid = 1; vol = 1; break;
  404.          case 5:  trk =  1; sid = 0; vol = 2; break;
  405.          case 6:  trk = 16; sid = 1; vol = 2; break;
  406.          default: trk = 32; sid = 0; vol = 2; break;
  407.       }
  408.       if (v != vol) {
  409.          if (volchg(vol, drv, headblk[1]) == -1) return(-1);
  410.       }
  411.    } else {
  412.       trk = 1; sid = 0; sct = ch*2 + 1;
  413.       if (nvol == 2) ye  = 199;
  414.       if (vol  != 1) {
  415.          vol = 1;
  416.          if (volchg(vol, drv, headblk[1]) == -1) return(-1);
  417.       }
  418.    }
  419.  
  420. /* work area open */
  421.    if ((fp = fopen(wname, "w+b")) == NULL) {
  422.       wareaerr(warea);
  423.       return(-1);
  424.    }
  425.  
  426.    helpcls( 80, 230, 560, 300);
  427.    sprintf( msg2, "バンド %d のデータを読み込み中です。", ch);
  428.    msgset(96, 255, msg2, col0);
  429.    sprintf( msg2, "ドライブ %d → 作業領域 %d", drv, warea);
  430.    msgset(96, 275, msg2, col0);
  431.  
  432. /* header write */
  433.    for ( i = 1; i <= 512; i++) headblk[0][i-1] = ' ';
  434.    sprintf( headblk[0], "WORK.AREA       ORIGINAL        BAND.%3d        LINEST.%4d", ch, linest);
  435.    /*                    123456789012345612345678901234561234567890123456        */
  436.    bsize = 512; bn = 1;
  437.    if (fwrite( headblk[0], bsize, bn, fp) != bn) {
  438.       fclose(fp); wareaerr(warea); return(-1);
  439.    }
  440.    if (fwrite( headblk[1], bsize, bn, fp) != bn) {
  441.       fclose(fp); wareaerr(warea); return(-1);
  442.    }
  443.    
  444. /* mos-1/landsat ---> work area */
  445.    /* sct = sid * 26 + sct; */
  446.    devno = 0x0020 | drv; /* 1MB floppy */
  447.    bsize = 512; bn = 1; seccnt = 2;
  448.    
  449.    s   = nch * 2;
  450.    while (1) {
  451.       for (i = ys; i <= ye; i++) {
  452.          ercnt = 0;
  453.          while(1) {
  454.             if (DKB_read( devno, trk, sid, sct, seccnt, wblk, &secnum) == 0) break;
  455.             { int i; for (i = 0; i < 30000; i++); }
  456.             if (++ercnt > 9) { fclose(fp); drverr(drv); return(-1); }
  457.          }
  458.          if (fwrite( wblk, bsize, bn, fp) != bn) {
  459.             fclose(fp); wareaerr(warea); return(-1);
  460.          }
  461.          sct = sct + s;
  462.          if (sct > 26) {
  463.             sct = sct - 26;
  464.             if (sid == 0) sid = 1;
  465.             else        { sid = 0; trk = trk + 1; }
  466.          }
  467.       }
  468.       if (ye == 399) break;
  469.       vol = vol + 1;
  470.       if (volchg( vol, drv, headblk[1]) == -1) { fclose(fp); return(-1); }
  471.       ys = ye + 1; ye = 399;
  472.       trk = 1; sid = 0; sct = ch * 2 + 1;
  473.    }
  474.    fclose(fp);
  475.    return(0);
  476. }
  477.  
  478.  
  479. void dataset2(int drv, int warea)
  480. {
  481. unsigned  ddadr[2];
  482. unsigned char page;
  483. char      buf[30175]; /* (397*152+7)/8*4 */
  484. int x, y;
  485. int mx, my;
  486.  
  487.    x = 60; y = 65;
  488.    page = 0;
  489.    BSETDATAADR(ddadr,  buf);
  490.    GDS_getBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+151);
  491.  
  492.    helpbox( x, y, x+390, y+120, "MOS-1/LANDSAT データ・ディスク内容");
  493.    if (dataset3( drv, warea) != 0) {
  494.       GDS_putBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+151, PSET);
  495.       return;
  496.    }
  497.    helpcls( 80, 230, 560, 300);
  498.    msgset(96, 255, "正常に終了しました。", col0);
  499.    msgset(96, 275, "確認ボタンを押してください。", col0);
  500.    recogin( 435, 275, 0);
  501.    GDS_putBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+151, PSET);
  502.    return;
  503. }
  504.  
  505. void dataset( int datadrive)
  506. {
  507. int bcl[16];
  508. int exec, com, com2, com3, com4;
  509. int mx, my, mosx=400, mosy=100;
  510. unsigned char page;
  511.  
  512.    page = 1;
  513.    GDS_displayPage(page);
  514.    gout();
  515.    page = 0;
  516.    GDS_writePage(page);
  517.    gout();
  518.       menubox( 80, 40, 560, 220, "データ読み込み(観測衛星画像データ → 作業領域)");
  519.       helpbox( 80,230, 560, 300, "メッセージ");
  520.  
  521.       msgset( 80, 70, " ○ ドライブ0", col0);
  522.       msgset( 80, 90, " ○ ドライブ1", col0);
  523.       msgset( 80,110, " ○ ドライブ2", col0);
  524.       msgset( 80,130, " ○ ドライブ3", col0);
  525.       msgset(320, 70, " ○ 作業領域1", col0);
  526.       msgset(320, 90, " ○ 作業領域2", col0);
  527.       msgset(320,110, " ○ 作業領域3", col0);
  528.       migiya(240, 90-4, col0);
  529.       msgset( 80,170, " ○ 終 了", col0);
  530.       execmsg(480, 190, col0);
  531.       calcu(600, 30, 0);
  532.  
  533.       GDS_displayPage(page);
  534.       gout();
  535.       locate(0,0,COFF);
  536.       MOS_disp(0);
  537.       exec = 0;
  538.       com  = com2 = datadrive + 1;
  539.       com3 = com4 = 7;
  540.  
  541.       while(1) {
  542.          if (com  == 1) msgset( 96, 70, "●", col0);
  543.          if (com  == 2) msgset( 96, 90, "●", col0);
  544.          if (com  == 3) msgset( 96,110, "●", col0);
  545.          if (com  == 4) msgset( 96,130, "●", col0);
  546.          if (com  == 6) msgset( 96,170, "●", col0);
  547.          if (com3 == 7) msgset(336, 70, "●", col0);
  548.          if (com3 == 8) msgset(336, 90, "●", col0);
  549.          if (com3 == 9) msgset(336,110, "●", col0);
  550.          dsetmsg(com, 1);
  551.          
  552.          if (exec == 1) {
  553.             if (1 <= com && com <= 4) {
  554.                dataset2(com-1, com3-6);
  555.                execmsg(480, 190, col0);
  556.                helpcls( 80,230, 560, 300);
  557.                exec = 0;
  558.                continue;
  559.             }
  560.             if (com == 6) { return; }
  561.          }
  562.          while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
  563.          if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
  564.          if (wabotchk(mx, my, 600, 60) == 1) continue;
  565.  
  566.          if (xychk16(mx, my, 96, 70) == 1) com = 1;
  567.          if (xychk16(mx, my, 96, 90) == 1) com = 2;
  568.          if (xychk16(mx, my, 96,110) == 1) com = 3;
  569.          if (xychk16(mx, my, 96,130) == 1) com = 4;
  570.          if (xychk16(mx, my, 96,170) == 1) com = 6;
  571.          if (xychk16(mx, my,336, 70) == 1) com3 = 7;
  572.          if (xychk16(mx, my,336, 90) == 1) com3 = 8;
  573.          if (xychk16(mx, my,336,110) == 1) com3 = 9;
  574.          if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
  575.             execmsg(480, 190, -1);
  576.             while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
  577.             if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
  578.                exec = 1;
  579.                continue;
  580.             } else {
  581.                exec = 0;
  582.                execmsg(480, 190, col0);
  583.                continue;
  584.             }
  585.          }
  586.          if (com != com2) {
  587.             if (com2 == 1) { msgset( 96, 70, "●", col7); msgset( 96, 70, "○", col0); }
  588.             if (com2 == 2) { msgset( 96, 90, "●", col7); msgset( 96, 90, "○", col0); }
  589.             if (com2 == 3) { msgset( 96,110, "●", col7); msgset( 96,110, "○", col0); }
  590.             if (com2 == 4) { msgset( 96,130, "●", col7); msgset( 96,130, "○", col0); }
  591.             if (com2 == 6) { msgset( 96,170, "●", col7); msgset( 96,170, "○", col0); }
  592.             dsetmsg(com2, 0);
  593.             com2 = com;
  594.          }
  595.          if (com3 != com4) {
  596.             if (com4 == 7) { msgset(336, 70, "●", col7); msgset(336, 70, "○", col0); }
  597.             if (com4 == 8) { msgset(336, 90, "●", col7); msgset(336, 90, "○", col0); }
  598.             if (com4 == 9) { msgset(336,110, "●", col7); msgset(336,110, "○", col0); }
  599.             com4 = com3;
  600.          }
  601.       }
  602. }
  603.  
  604.  
  605. void dsavemsg(int com, int com9, int sw)
  606. {
  607.    char hmsg1[80], hmsg2[80];
  608.    int col;
  609.  
  610.    hmsg1[0] = '\0'; hmsg2[0] = '\0';
  611.  
  612.    if (com == 1 || com == 2 || com == 3) {
  613.       strcpy(hmsg1, "作業領域と退避・復帰(矢印部分)を選択してください。");
  614.       strcpy(hmsg2, "MS-DOSのファイル名を設定ししてください。");
  615.    }
  616.  
  617. /*
  618.    if (com == 1) {
  619.       if (com9 == 0) strcpy(hmsg1, "作業領域1のデータを退避します。");
  620.       else           strcpy(hmsg1, "作業領域1のデータを復帰します。");
  621.       strcpy(hmsg2, "MS-DOSのファイル名を設定ししてください。");
  622.    }
  623.  
  624.    if (com == 2) {
  625.       if (com9 == 0) strcpy(hmsg1, "作業領域2のデータを退避します。");
  626.       else           strcpy(hmsg1, "作業領域2のデータを復帰します。");
  627.       strcpy(hmsg2, "MS-DOSのファイル名を設定ししてください。");
  628.    }
  629.  
  630.    if (com == 3) {
  631.       if (com9 == 0) strcpy(hmsg1, "作業領域3のデータを退避します。");
  632.       else           strcpy(hmsg1, "作業領域3のデータを復帰します。");
  633.       strcpy(hmsg2, "MS-DOSのファイル名を設定ししてください。");
  634.    }
  635. */
  636.  
  637.    if (com == 6) {
  638.       strcpy(hmsg1, "メイン・メニューにもどります。");
  639.    }
  640.  
  641.    if (com == 8) {
  642.       strcpy(hmsg1, "ファイル名をキーボードで入力してください。");
  643.       strcpy(hmsg2, "ファイル名は半角で8文字までです。");
  644.    }
  645.  
  646.    if (sw == 0) col = col7;
  647.    else         col = col0;
  648.  
  649.    msgset(96, 255, hmsg1, col);
  650.    msgset(96, 275, hmsg2, col);
  651. }
  652.  
  653. void namin(char fnam[])
  654. {
  655.    char dirnam[64], fname[13];
  656.    int  i;
  657.    char strw[128];
  658.    
  659.    color(1, 0);
  660.    dirnam[0] = 0; fname[0] = 0;
  661.    helpbox( 320, 110, 580, 170, "ファイル名");
  662.    sprintf(strw, "%s\n", fnam);
  663.    symbol_( 328, 140, strw, 1,1, col0, 0 ,PSET);
  664.    gfsel(240, 32, "ファイルの選択", dirnam, fname);
  665.    if (strlen(dirnam) > 3) { /* ex A:\ */
  666.       strcat(dirnam, "\\");
  667.    }
  668.    if (strlen(fname) == 0) fnam[0] = 0;
  669.    else {
  670.       strcat(dirnam, fname);
  671.       strcpy(fnam, dirnam);
  672.    }
  673.    helpbox( 320, 110, 580, 170, "ファイル名");
  674.    sprintf(strw, "%s\n", fnam);
  675.    symbol_( 328, 140, strw, 1,1, col0, 0 ,PSET);
  676.    /* msgset( 336, 144, fnam, col0);  16*21, 16*9 */
  677.    /* qas(41, 9, "", fnam, 30); / * 8*41, 16*9 */
  678. }
  679.  
  680. void dsaveerr( void)
  681. {
  682. unsigned  ddadr[2];
  683. unsigned char page;
  684. char      buf[30175]; /* (397*152+7)/8*4 */
  685. int x, y;
  686. int mx, my;
  687.  
  688.    x = 60; y = 65;
  689.    page = 0;
  690.    BSETDATAADR(ddadr,  buf);
  691.    GDS_getBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+151);
  692.  
  693.    helpbox( x, y, x+390, y+120, "エラー");
  694.    msgset(x+16, y+30, "エラーが発生しました。", col10);
  695.  
  696.    recogmsg(x+350, y+95, col0);
  697.    while (1) {
  698.       while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
  699.       if (xychk(mx, my, x+350, y+95, x+350+33, y+95+18) == 1) {
  700.          recogmsg(x+350, y+95, -1);
  701.          while((MOS_rdpos(&mx, &my) & 0x01) == 1);
  702.          if (xychk(mx, my, x+350, y+95, x+350+33, y+95+18) == 0) {
  703.             recogmsg(x+350, y+95, col0);
  704.             continue;
  705.          } else {
  706.             break;
  707.          }
  708.       }
  709.    }
  710.    GDS_putBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+151, PSET);
  711.    return;
  712. }
  713.  
  714. void datasave2(int warea, char fnam[])
  715. {
  716. char  wstr[80];
  717.    
  718.    if (strlen(fnam) == 0) return;
  719.    sprintf(wstr, "copy %s\\warea%1d.lnd %s", workdir, warea, fnam);
  720.    if (system( wstr) == -1) dsaveerr();
  721.    return;
  722. }
  723.  
  724. void dataload2(int warea, char fnam[])
  725. {
  726. char  wstr[80];
  727.  
  728.    if (strlen(fnam) == 0) return;
  729.    sprintf(wstr, "copy %s %s\\warea%1d.lnd", fnam, workdir, warea);
  730.    if (system( wstr) == -1) dsaveerr();
  731.    return;
  732. }
  733.  
  734. void dsmsgcls()
  735. {
  736.    line(80+1, 230+21, 560-1, 300-1, PSET, col7, 2, 0xffff);
  737. }
  738.  
  739. void datasave()
  740. {
  741. int bcl[16];
  742. int exec, com, com2, com3, com4, com9;
  743. int mx, my, mosx=400, mosy=100;
  744. unsigned char page;
  745. char  fnam[64];
  746.  
  747.    fnam[0]='\0';
  748.    /* strcpy(fnam, "SDFILE"); */
  749.   
  750.    page = 1;
  751.    GDS_displayPage(page);
  752.    gout();
  753.    page = 0;
  754.    GDS_writePage(page);
  755.    gout();
  756.       menubox( 80, 40, 560, 220, "作業領域の退避・復帰");
  757.       helpbox( 80,230, 560, 300, "メッセージ");
  758.  
  759.       msgset( 80, 70, " ○ 作業領域1", col0);
  760.       msgset( 80, 90, " ○ 作業領域2", col0);
  761.       msgset( 80,110, " ○ 作業領域3", col0);
  762.       msgset(320, 90, " ○ MS-DOS", col0);
  763.       symbol_( 240+12,    90, "■", 3, 1, col0, 0, PSET);
  764.       symbol_( 240+48, 90+23, "▼", 2, 1, col0, 1, PSET);
  765.       symbol_( 240,    90+23, "▲", 2, 1, col8, 1, PSET);
  766.       msgset( 80,170, " ○ 終 了", col0);
  767.       execmsg(480, 190, col0);
  768.       calcu(600, 30, 0);
  769.       
  770.       GDS_displayPage(page);
  771.       gout();
  772.       locate(0,0,COFF);
  773.       MOS_disp(0);
  774.       exec = 0;
  775.       com  = com2 = 1;
  776.       com3 = com4 = 0;
  777.       com9 = 0;
  778.  
  779.       while(1) {
  780.          if (com3 == 8) {
  781.             msgset(336, 90, "●", col0);
  782.             dsmsgcls();
  783.             dsavemsg(com3, com9, 1);
  784.             namin(fnam);
  785.             msgset(336, 90, "●", col7); msgset(336, 90, "○", col0);
  786.             dsmsgcls();
  787.             dsavemsg(com2, com9, 1);
  788.             com3 = 0;
  789.          } else {
  790.             dsmsgcls();
  791.             if (com  == 1) msgset( 96, 70, "●", col0);
  792.             if (com  == 2) msgset( 96, 90, "●", col0);
  793.             if (com  == 3) msgset( 96,110, "●", col0);
  794.             if (com  == 6) msgset( 96,170, "●", col0);
  795.             dsavemsg(com, com9, 1);
  796.          }
  797.          while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
  798.          if (exec == 1) {
  799.             if (com9 == 0 && 1 <= com && com <= 3) { datasave2(com, fnam); }
  800.             if (com9 == 1 && 1 <= com && com <= 3) { dataload2(com, fnam); }
  801.             if (com == 6) { return; }
  802.             exec = 0;
  803.             execmsg(480, 190, col0);
  804.          }
  805.          while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
  806.          if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
  807.          if (wabotchk(mx, my, 600, 60) == 1) continue;
  808.  
  809.          if (xychk16(mx, my, 96, 70) == 1) com = 1;
  810.          if (xychk16(mx, my, 96, 90) == 1) com = 2;
  811.          if (xychk16(mx, my, 96,110) == 1) com = 3;
  812.          if (xychk16(mx, my, 96,170) == 1) com = 6;
  813.          if (xychk16(mx, my,336, 90) == 1) com3 = 8;
  814.          if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
  815.             execmsg(480, 190, -1);
  816.             while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
  817.             if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
  818.                exec = 1;
  819.                continue;
  820.             } else {
  821.                exec = 0;
  822.                execmsg(480, 190, col0);
  823.                continue;
  824.             }
  825.          }
  826.          if (xychk( mx, my, 240+48, 90+23-32, 240+64, 90+23) == 1) {
  827.             symbol_( 240+48, 90+23, "▼", 2, 1, col0, 1, PSET);
  828.             symbol_( 240,    90+23, "▲", 2, 1, col8, 1, PSET);
  829.             com9 = 0;
  830.             continue;
  831.          }
  832.          if (xychk( mx, my, 240, 90+23-32, 240+16, 90+23) == 1) {
  833.             symbol_( 240+48, 90+23, "▼", 2, 1, col8, 1, PSET);
  834.             symbol_( 240,    90+23, "▲", 2, 1, col0, 1, PSET);
  835.             com9 = 1;
  836.             continue;
  837.          }
  838.          if (com != com2) {
  839.             if (com2 == 1) { msgset( 96, 70, "●", col7); msgset( 96, 70, "○", col0); }
  840.             if (com2 == 2) { msgset( 96, 90, "●", col7); msgset( 96, 90, "○", col0); }
  841.             if (com2 == 3) { msgset( 96,110, "●", col7); msgset( 96,110, "○", col0); }
  842.             if (com2 == 6) { msgset( 96,170, "●", col7); msgset( 96,170, "○", col0); }
  843.             com2 = com;
  844.          }
  845.       }
  846. }
  847.  
  848.  
  849.